// $Id: future.h 33 2011-04-14 18:49:15Z cedric.shih@gmail.com $
/*
 * Copyright (C) 2011 Cedric Shih <cedric.shih@gmail.com>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation; either version 2.1 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 */

#ifndef NIOFUTURE_H_
#define NIOFUTURE_H_

#ifdef __cplusplus
extern "C" {
#endif

struct niofuture;

struct niofuture *niofuture_new(struct nioreactor *reactor);

void niofuture_free(struct niofuture *future);

struct timeval;

struct niosocket;

enum niofuture_flag {
	NIO_TIMEUP = 0x01 << 1,
	NIO_READABLE = 0x01 << 2,
	NIO_WRITABLE = 0x01 << 3,
};

typedef void (*niofuture_cb)(struct niofuture *future,
		struct niosocket *socket, int flags, void *cbarg);

int niofuture_writable(struct niofuture *future, struct niosocket *socket,
		struct timeval *timeout, niofuture_cb cb, void *cbarg);

int niofuture_readable(struct niofuture *future, struct niosocket *socket,
		struct timeval *timeout, niofuture_cb cb, void *cbarg);

int niofuture_timeup(struct niofuture *future,
		struct timeval *timeout, niofuture_cb cb, void *cbarg);

int niofuture_cancel(struct niofuture *future);

#ifdef __cplusplus
}
#endif

#endif /* NIOFUTURE_H_ */
